package com.ad.pet.app.mall.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.ad.pet.R;
import com.ad.pet.models.remote.mall.WeekDoor;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by liuyixiang on 2019/12/3.
 */

public class DateWeekAdapter extends BaseQuickAdapter<WeekDoor,BaseViewHolder> {
    public DateWeekAdapter( @Nullable List<WeekDoor> data) {
        super(R.layout.item_week_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, WeekDoor item) {
        TextView tvWeek = helper.getView(R.id.tv_week);
        TextView tvDay = helper.getView(R.id.tv_day);
        View view = helper.getView(R.id.view_lien);
        tvWeek.setText(item.getWeekday());
        tvDay.setText(item.getDate());
        if (item.isChose()){
            view.setVisibility(View.VISIBLE);
            tvWeek.setTextColor(mContext.getResources().getColor(R.color.colorAccent));
            tvDay.setTextColor(mContext.getResources().getColor(R.color.colorAccent));
        }else {
            view.setVisibility(View.INVISIBLE);
            tvDay.setTextColor(mContext.getResources().getColor(R.color.black3d));
            tvWeek.setTextColor(mContext.getResources().getColor(R.color.black3d));
        }
    }

    public WeekDoor getWeekDoor(){
        WeekDoor weekDoor =null;
        for (int i = 0; i <mData.size() ; i++) {
            if (mData.get(i).isChose()){
                weekDoor = mData.get(i);
                break;
            }
        }
        return weekDoor;
    }
}
